package com.atguigu.realtime.function;

import com.atguigu.realtime.util.IkUtil;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

import java.util.List;

/**
 * @Author lzc
 * @Date 2022/7/24 15:09
 */
@FunctionHint(output = @DataTypeHint("row<keyword string>"))
public class IkAnalyzer extends TableFunction<Row> {
    public void eval(String kw){
        /*
        对kw进行分词,
        kw分出几个就输出几行
         */
        List<String> words =  IkUtil.split(kw);
    
        for (String word : words) {
            collect(Row.of(word));
            
        }
    }
}
